home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0295.lzh / AMOSLIST / text0079.txt < prev    next >
Encoding:
Text File  |  1995-03-01  |  2.9 KB  |  94 lines

  1. For all who asked.  Here's the 4 button code.
  2.  
  3. The program is very simple and should be self explanatory.
  4. I added some extra comments to help with the harder points.
  5.  
  6. The modification to the sega joypad are very simple, just cross
  7. the 5 and 7 pins.  If you want to open the joypad and perform a 
  8. solder job fine.  But the best thing to do is to run down to Radio Shack
  9. and get the parts to build an adapter, you will need:
  10.  1 Male 9 Pin kit
  11.  1 Female 9 Pin kit
  12.  2 plastic shielding covers
  13.  wire
  14.  
  15. Cut the shielding covers in half and glue the two covers together 
  16. and glue the two bottoms together.  Assemble the plugs remembering
  17. to cross 5 on one end with 7 on the other.  The pin out should look
  18. like this:
  19.  
  20.   1---------1
  21. 6-------------6
  22.   2---------2
  23. 7---\     /---7
  24.   3--\---/--3
  25. 8-----\-/-----8
  26.   4----x----4
  27. 9-----/-\-----9
  28.   5--/   \--5
  29.  
  30. Solder no two wires together. Place the shielding covers on and tape
  31. shut.  You can glue the covers shut once your sure it works ok.
  32.  
  33. The code is based on a article in Amiga Format that came out last
  34. summer, I don't remember the exact issue but the assembly version
  35. of this code was on the cover disk.
  36.  
  37. The code could be shortened in many different ways, but for 
  38. simplicity heres the long version.
  39.  
  40. /------Cut and remove commments, but not the procedure header------\
  41.  
  42. Do 
  43.    Proc SEGAFIRE[0]
  44.    Print Bin$(Param,4)
  45.    Proc SEGAFIRE[1]
  46.    Print Bin$(Param,4)
  47. Loop 
  48.  
  49. Procedure SEGAFIRE[BUTTON]
  50.    '  Amiga 4-button joystick code... 
  51.    '
  52.    '  Stick discovery by Ed Bamber
  53.    '  Code created by Anthony Ball
  54.    '  Converted to AMOS by Brad Gust
  55.    '
  56.    '  (C)1992 Anthony Ball & Edmund Bamber
  57.    '  (C)1994 Brad Gust 
  58.    '
  59.    '  Requires a SEGA joystick with wires 5 & 7 swapped 
  60.    '
  61.    REG=$0
  62.    If BUTTON
  63.       If Fire(1)                         Read normal button one port 1
  64.          REG=REG+$4                      Set status bit
  65.       End If 
  66.       If Not Btst(6,$DFF016)             Read normal button Two port 1
  67.          REG=REG+$2                      Set status bit
  68.       End If 
  69.       Doke $DFF034,$E000            Force port 1 into a different mode.
  70.       If Fire(1)                    Reading button 1 again gives different
  71. answer
  72.          REG=REG+$8                 Set status bit
  73.       End If 
  74.       If Not Btst(6,$DFF016)        Read button 2 again, different answer
  75.          REG=REG+$1                 Set status bit
  76.       End If 
  77.    Else 
  78.       If Fire(0)                         Read normal button one port 0
  79.          REG=REG+$4                      Set status bit
  80.       End If 
  81.       If Not Btst(2,$DFF016)             Read normal button Two port 0
  82.          REG=REG+$2                      Set status bit
  83.       End If 
  84.       Doke $DFF034,$E00            Force port 0 into a different mode.
  85.       If Fire(0)                   ....
  86.          REG=REG+$8                ....
  87.       End If 
  88.       If Not Btst(2,$DFF016)       ....
  89.          REG=REG+$1                ....
  90.       End If 
  91.    End If 
  92. End Proc[REG]
  93.  
  94.